import Vue from 'vue'
import VueRouter from 'vue-router'
import EditPage from '../components/EditPage.vue'
import DisplayPage from '../components/DisplayPage.vue'
import IndexPage from '../components/indexPage.vue'
import TestPage from '../components/test.vue'
import scheduledTaskPage from '../components/scheduledTask.vue'
import ManagementCom from '../components/ManagementCom.vue'
import lockPageCom from '../components/lockPage.vue'
import pageManage from '../components/pageManage.vue'
import AddUserPermissionCom from '../components/AddUserPermission.vue'
import UserManagementCom from '../components/UserManagementCom.vue'
import NewEditPage from '../components/NewEditPage.vue'
import HomePage from '../components/homePage.vue'
import UserManageMent from '../components/UserManageMent.vue'
import AddUserPage from '../components/AddUserPage.vue'
import EditUserPage from '../components/EditUserPage.vue'
import PermissionManagementPage from '../components/PermissionManagement.vue'
Vue.use(VueRouter)

const originalPush = VueRouter.prototype.push
// 修改原型对象中的push方法
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

const routes = [
  {
    path: "/homePage",
    name: "HomePage",
    component: HomePage
  },
  {
    path: '/',
    redirect: "/lockPage"
  },
  {
    path: "/editPage/:pageName/:language",
    name: "EditPage",
    component: NewEditPage
  },
  {
    path: "/oldEditPage/:pageName/:language",
    name: "oldEditPage",
    component: EditPage
  },
  {
    path: "/displayPage/:pageName/:language",
    name: "displayPage",
    component: DisplayPage
  },
  {
    path: "/index",
    name: "index",
    component: IndexPage,
    children: [
      {
        path: '/',
        redirect: "/pageManage"
      },
      {
        path: "/pageManage",
        name: "pageManage",
        component: pageManage
      },
      {
        path: "/scheduledTask",
        name: "scheduledTask",
        component: scheduledTaskPage
      },
      {
        path: '/manageMent',
        name: 'manageMent',
        component: ManagementCom
      },
      {
        path: "/userManageMent",
        name: "userManageMent",
        component: UserManageMent
      },
      {
        path: "/AddUserPermissionCom/:id",
        name: 'AddUserPermissionCom',
        component: AddUserPermissionCom
      },
      {
        path: "/AddUserPage",
        name: "AddUserPage",
        component: AddUserPage
      },
      {
        path: "/EditUserPage/:id",
        name: "EditUserPage",
        component: EditUserPage
      },
      {
        path:"/PermissionManagementPage/:id",
        name:"PermissionManagement",
        component:PermissionManagementPage
      }
    ]
  },
  {
    path: "/test",
    name: "test",
    component: TestPage
  },
  {
    path: "/lockPage",
    name: "lockPage",
    component: lockPageCom
  },


  {
    path: '/about',
    name: 'about',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue')
  }
]

const router = new VueRouter({
  mode: 'hash',
  base: process.env.BASE_URL,
  routes
})

export default router
